package main

import (
	"fmt"
	"net/http"
	"net/http/httputil"
)

func main() {
	//httpDemo()
	httpHeaderDemo()
}

func httpDemo() {
	resp, _ := http.Get("http://www.imooc.com")
	defer resp.Body.Close()

	response, _ := httputil.DumpResponse(resp, true)
	fmt.Printf("%s\n", string(response))

}
func httpHeaderDemo() {
	request, _ := http.NewRequest(http.MethodGet, "http://www.imooc.com", nil)
	request.Header.Add("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac 05 X) AppleWebKit/602.1.50")
	resp, _ := (&http.Client{}).Do(request)
	defer resp.Body.Close()
	response, _ := httputil.DumpResponse(resp, true)
	fmt.Printf("%s\n", string(response))
}
